package com.vcar.LDiceClient.command
{
    import com.vcar.LDiceClient.config.MediatorName;
    import com.vcar.LDiceClient.dataproxy.module.ModuleInfo;
    
    import flash.events.Event;
    import flash.system.ApplicationDomain;
    
    import mx.events.ModuleEvent;
    
	import org.puremvc.as3.interfaces.INotification;
	import org.puremvc.as3.patterns.command.SimpleCommand;
    /**
     * 改变主场景的module
     * @author rhj
     *
     */	
    public class ChangeModuleCommand extends SimpleCommand
    {
        
        public function ChangeModuleCommand()
        {
            super();
        }


        override public function execute(notification:INotification) : void
        {
			var destModule:ModuleInfo;
            var m:LDiceMediator = facade.retrieveMediator(MediatorName.LDiceClient) as LDiceMediator;
            destModule=notification.getBody() as ModuleInfo;
            m.mainModule.unloadModule();
			
			m.mainModule.applicationDomain=ApplicationDomain.currentDomain;
			m.app.moduleData=destModule.data;
			m.mainModule.loadModule(destModule.url);
        }

    }
}

